import OpenGL.GL as gl

class Shader:
    def __init__(self, type: int, file_name:str) -> None:
        self.shader_id = gl.glCreateShader(type)
        with open(file_name) as file:
            source = file.read()
            gl.glShaderSource(self.shader_id, source)
            gl.glCompileShader(self.shader_id)
        status = gl.glGetShaderiv(self.shader_id, gl.GL_COMPILE_STATUS)
        if status == gl.GL_FALSE:
            log = gl.glGetShaderInfoLog(self.shader_id)
            print("Shader {} Error Log: {}".format(type, log))


    def delete(self)-> None:
        if gl.glIsShader(self.shader_id):
            gl.glDeleteShader(self.shader_id)
